﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Data;
using Caliburn.Micro;
using DomusDotNet.Sbm.Client.WP7.Services;

namespace DomusDotNet.Sbm.Client.WP7.Framework
{
    public class ISBNtoCoverImageConverter: IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var isbn = (string)value;
            if (parameter == null) throw new ArgumentNullException("parameter", "A size (among Thumbnail and Detail) should be specified as parameter");
            var size = (CoverSize)Enum.Parse(typeof(CoverSize), (string)parameter, true);
            var provider = IoC.Get<ICoverProvider>();

            return provider.GetCover(isbn, size);
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }
}
